import {
  getGoodsAmountListData,
  getGoodsAddressSale,
  getGoodsCategoryCount,
  getGoodsCategoryFavor,
  getGoodsCategorySale
} from "@/service/analysis/analysis";

import { defineStore } from "pinia";

interface IAnalysisState {
  amountList: any[];
  goodsCategoryCount: any[];
  goodsCategorySale: any[];
  goodsCategoryFavor: any[];
  goodsAddressSale: any[];
}

const useAnalysisStore = defineStore("analysis", {
  state: (): IAnalysisState => ({
    amountList: [],
    goodsCategoryCount: [],
    goodsCategorySale: [],
    goodsCategoryFavor: [],
    goodsAddressSale: []
  }),
  actions: {
    async fetchAnalysisDataAction() {
      getGoodsAmountListData().then((res) => {
        this.amountList = res.data;
      });
      getGoodsCategoryCount().then((res) => {
        this.goodsCategoryCount = res.data;
      });
      getGoodsCategorySale().then((res) => {
        this.goodsCategorySale = res.data;
      });
      getGoodsCategoryFavor().then((res) => {
        this.goodsCategoryFavor = res.data;
      });
      getGoodsAddressSale().then((res) => {
        this.goodsAddressSale = res.data;
      });
    }
  }
});

export default useAnalysisStore;
